package cn.wolfcode.wolf2w.redis.util;

import cn.wolfcode.wolf2w.util.Consts;
import lombok.Getter;

/**
 * redisKeys的统一处理
 */
@Getter
public enum RedisKeys {

    STRATEGT_THUMBSUP("strategt_thumbsup", -1L),
    STRATEGT_USER_FAVOR("strategt_user_favor", -1L),
    STRATEGT_STATIS_VO("strategt_statis_vo", -1L),
    VERIFY_CODE("verify_code", Consts.VERIFY_CODE_VAI_TIME * 60L),
    USER_LOGIN("user_login", Consts.USER_INFO_TOKEN_VAI_TIME * 60L);
    private String prefix;  //  前缀
    private Long time;  //  存活时间
    //  构造器
    private RedisKeys(String prefix, Long time){
        this.prefix = prefix;
        this.time = time;
    }

    public String join(String... keys){
        StringBuilder sb = new StringBuilder(80);
        sb.append(prefix);
        for (String key : keys) {
            sb.append(":")
                    .append(key);
        }
        return sb.toString();
    }
}
